package com.salt.modules.bug.controller;

import com.salt.common.json.AjaxJson;
import com.salt.core.persistence.Page;
import com.salt.core.web.BaseController;
import com.salt.modules.bug.entity.SysBugData;
import com.salt.modules.bug.service.SysBugDataService;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description  bug管理
 * @Author zy
 * @Date 2023-02-10
 * @Version 1.0.1
 */
@RestController
@AllArgsConstructor
@RequestMapping("/sys/bug/data")
public class SysBugDataController extends BaseController {
    @Autowired
    private SysBugDataService sysBugDataService;

    /**
     * @param sysBugData 查询内容
     * @param pageNo       页码
     * @param pageSize     每页大小
     * @return
     * @Author yan
     */
    @ApiOperation(value = "分页查询:根据前台参数分页查询")
    @GetMapping("allLimit")
    public AjaxJson list(SysBugData sysBugData, @RequestParam(required = false) int pageNo, @RequestParam(required = false) int pageSize) {
        Page<SysBugData> page = sysBugDataService.findPage(new Page<SysBugData>(pageNo, pageSize), sysBugData);
        return AjaxJson.success().put("page", page);
    }

    /**
     * @Author yan
     */
    @ApiOperation(value = "添加数据")
    @PostMapping("add")
    public AjaxJson add(SysBugData sysBugData) {
        sysBugDataService.insert(sysBugData);
        return AjaxJson.success();
    }

    /**
     * @Author yan
     */
    @ApiOperation(value = "删除数据")
    @GetMapping("delete")
    public AjaxJson delete(String id) {
        sysBugDataService.deleteById(id);
        return AjaxJson.success();
    }
}
